#!/bin/bash
WORK_PATH=$(readlink -f ${0} | xargs dirname)
script_name=$(basename $0)
branch_info="${WORK_PATH}/${script_name%\.*}_branch_info_$(date +%Y%m%d%H%M%S).txt"

SP="v97B"
GITHUB_URL="https://github.tmc-stargate.com"
GITHUB_YOCTO_BRANCH="feature/yocto-build"
# GITHUB_YOCTO_BRANCH="feature/yocto-build-hotfix-v995"
GITHUB_MKDOCS_BRANCH="feature/mkdocs-build"
GITHUB_DRAFT_BRANCH="feature/mkdocs-build-draft"
GIT_REPO_LIST=(
	# # # # code
	arene-os-services-cockpit-tmc-wa:meta-tagl:code
	arene-os-services-cockpit-tmc-wa:meta-arene-ivi-userland:code
	arene-os-services-cockpit-tmc-wa:vehicle_cooperation:code
	arene-os-services-cockpit-tmc-wa:arene-ivi-vehicle-control:code
	arene-os-services-cockpit-tmc-wa:arene-ivi-appsvc-settingsprovider:code
	arene-os-services-cockpit-wa:arene-ivi-appsvc-vehiclesettings:code
	arene-os-services-cockpit-tmc-wa:arene-cockpit-api:code
	arene-os-services-cockpit-tmc-wa:vehicleinfo:code
	arene-os-services-cockpit-tmc-wa:arene-ivi-misc-sdk-hal-docker-build:code
	arene-os-services-cockpit-tmc-wa:nsframework:code
	arene-os-services-cockpit-tmc-wa:peripheralservice:code
	arene-os-services-cockpit-tmc-wa:vehicleservice:code
	arene-os-services-cockpit-tmc-wa:systemservice:code
	arene-os-services-cockpit-tmc-wa:meta-arene-ivi:code
	arene-os-services-cockpit-tmc-wa:arene-ivi-hal-backup-impl-virtual:code
	# # # # docs
	arene-os-services-cockpit-tmc-wa:arene-cockpit-api:draft
	arene-os-services-cockpit-tmc-wa:ed-assp-appsvc-settingsprovider:draft
	arene-os-services-cockpit-wa:ed-asvs-appsvc-vehiclesettings:draft
	arene-os-services-cockpit-tmc-wa:ed-vhct-vehicle-control:draft
	arene-os-services-cockpit-tmc-wa:ei-vhct-vehicle-control:draft
	arene-os-services-cockpit-tmc-wa:arene-ivi-application-developer-guide-mkdocs:docs
	arene-os-services-cockpit-wa:arene-ivi-misc-unit-management:docs
	arene-os-services-cockpit-tmc-wa:wt-all:docs
)

GITHUB_HOTFIX_TARGS="v9.9.0"
GITHUB_HOTFIX_YOCTO="feature/yocto-build-hotfix-v995"
GITHUB_HOTFIX_MKDOCS="feature/mkdocs-build-hotfix-v995"
HOTFIX_GIT_REPO_LIST=(
	# # # code
	# arene-os-services-cockpit-tmc-wa:meta-tagl:code
	# arene-os-services-cockpit-tmc-wa:meta-arene-ivi-userland:code
	# arene-os-services-cockpit-tmc-wa:vehicle_cooperation:code
	# arene-os-services-cockpit-tmc-wa:arene-ivi-vehicle-control:code
	# arene-os-services-cockpit-tmc-wa:arene-ivi-appsvc-settingsprovider:code
	# arene-os-services-cockpit-wa:arene-ivi-appsvc-vehiclesettings:code
	# arene-os-services-cockpit-tmc-wa:arene-cockpit-api:code
	# arene-os-services-cockpit-tmc-wa:vehicleinfo:code
	# arene-os-services-cockpit-tmc-wa:arene-ivi-misc-sdk-hal-docker-build:code
	# arene-os-services-cockpit-tmc-wa:nsframework:code
	# arene-os-services-cockpit-tmc-wa:peripheralservice:code
	# arene-os-services-cockpit-tmc-wa:vehicleservice:code
	# arene-os-services-cockpit-tmc-wa:systemservice:code
	# arene-os-services-cockpit-tmc-wa:meta-arene-ivi:code
	# arene-os-services-cockpit-tmc-wa:arene-ivi-hal-backup-impl-virtual:code
	# # # docs
	# arene-os-services-cockpit-tmc-wa:arene-cockpit-api:docs
	# arene-os-services-cockpit-tmc-wa:ed-assp-appsvc-settingsprovider:docs
	# arene-os-services-cockpit-wa:ed-asvs-appsvc-vehiclesettings:docs
	# arene-os-services-cockpit-tmc-wa:ed-vhct-vehicle-control:docs
	# arene-os-services-cockpit-tmc-wa:ei-vhct-vehicle-control:docs
	# arene-os-services-cockpit-tmc-wa:arene-ivi-application-developer-guide-mkdocs:docs
	# arene-os-services-cockpit-wa:arene-ivi-misc-unit-management:docs
	# arene-os-services-cockpit-tmc-wa:wt-all:docs
)

function create_release_branch ()
{
	local log="${WORK_PATH}/${SP}_create_branch.log"
	local commit_id_file="${WORK_PATH}/${SP}_release_commit_id.txt"
	:> ${log}
	:> ${commit_id_file}
	for repo_info in ${GIT_REPO_LIST[@]}; do
		tmp_array=(${repo_info//:/ })
		group_name=${tmp_array[0]}
		repo_name=${tmp_array[1]}
		branch_type=${tmp_array[2]}
		ret_code=0

		echo ">>>>>>>> ${repo_name} => create github branch start <<<<<<<<" | tee -a ${log}
		github_repo_name="${repo_name}_github"
		# git update
		if [[ -d ${github_repo_name} ]] && [[ -e ${github_repo_name}/.git ]] ; then
			pushd ${github_repo_name} >> ${log}
			{
				git reset --hard HEAD >/dev/null 2>&1
				git clean -df >/dev/null 2>&1
				git remote update origin --prune >/dev/null 2>&1
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		else
			## gitlab clone
			git clone --progress "${GITHUB_URL}/${group_name}/${repo_name}.git" ${github_repo_name} 2>${WORK_PATH}/.git_progress.log
			pushd ${github_repo_name} >> ${log}
			{
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		fi
		# create branch
		if [[ ${ret_code} -eq 0 ]]; then
			git pull  >>${log} 2>&1
			echo "######### ${repo_name} #########" >> ${commit_id_file}
			if [[ ${branch_type} == "code" ]]; then
				echo ">>>>>>>> create branch = ${GITHUB_YOCTO_BRANCH} START" >> ${log}
				git checkout -b ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
				git push -f origin ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
				SRCREV="${GITHUB_YOCTO_BRANCH}_commit_id = \"$(git rev-parse HEAD)\""
				echo ${SRCREV}  >> ${commit_id_file}
				git checkout master  >>${log} 2>&1
				git branch -D ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
				echo ">>>>>>>> create branch = ${GITHUB_YOCTO_BRANCH} END" >> ${log}
				echo ""  >> ${log}
			else
				echo ">>>>>>>> create branch = ${GITHUB_MKDOCS_BRANCH} START" >> ${log}
				git checkout -b ${GITHUB_MKDOCS_BRANCH}  >>${log} 2>&1
				git push -f origin ${GITHUB_MKDOCS_BRANCH}  >>${log} 2>&1
				SRCREV="${GITHUB_MKDOCS_BRANCH}_commit_id = \"$(git rev-parse HEAD)\""
				echo ${SRCREV}  >> ${commit_id_file}
				git checkout master  >>${log} 2>&1
				git branch -D ${GITHUB_MKDOCS_BRANCH}  >>${log} 2>&1
				echo ">>>>>>>> create branch = ${GITHUB_MKDOCS_BRANCH} END" >> ${log}
				echo ""  >> ${log}
			fi
			if [[ ${branch_type} == "draft" ]]; then
				echo ">>>>>>>> create branch = ${GITHUB_DRAFT_BRANCH} START" >> ${log}
				git checkout draft  >>${log} 2>&1
				git pull  >>${log} 2>&1
				git checkout -b ${GITHUB_DRAFT_BRANCH}  >>${log} 2>&1
				git push -f origin ${GITHUB_DRAFT_BRANCH}  >>${log} 2>&1
				SRCREV="${GITHUB_DRAFT_BRANCH}_commit_id = \"$(git rev-parse HEAD)\""
				echo ${SRCREV}  >> ${commit_id_file}
				git checkout master  >>${log} 2>&1
				git branch -D ${GITHUB_DRAFT_BRANCH}  >>${log} 2>&1
				echo ">>>>>>>> create branch = ${GITHUB_DRAFT_BRANCH} END" >> ${log}
			fi
			echo "" >> ${commit_id_file}
		fi
		popd >> ${log}
		echo ">>>>>>>> ${repo_name} => create github branch end <<<<<<<<" | tee -a ${log}
		echo "" >> ${log}
		echo "" >> ${log}
	done
}

function delete_release_branch ()
{
	local log="${WORK_PATH}/${SP}_delete_branch.log"
	local commit_id_file="${WORK_PATH}/${SP}_release_delete_commit_id.txt"
	:> ${log}
	:> ${commit_id_file}
	for repo_info in ${GIT_REPO_LIST[@]}; do
		tmp_array=(${repo_info//:/ })
		group_name=${tmp_array[0]}
		repo_name=${tmp_array[1]}
		branch_type=${tmp_array[2]}
		ret_code=0

		echo ">>>>>>>> ${repo_name} => create github branch start <<<<<<<<" | tee -a ${log}
		github_repo_name="${repo_name}_github"
		# git update
		if [[ -d ${github_repo_name} ]] && [[ -e ${github_repo_name}/.git ]] ; then
			pushd ${github_repo_name} >> ${log}
			{
				git reset --hard HEAD >/dev/null 2>&1
				git clean -df >/dev/null 2>&1
				git remote update origin --prune >/dev/null 2>&1
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		else
			## gitlab clone
			git clone --progress "${GITHUB_URL}/${group_name}/${repo_name}.git" ${github_repo_name} 2>${WORK_PATH}/.git_progress.log
			pushd ${github_repo_name} >> ${log}
			{
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		fi
		# delete branch
		if [[ ${ret_code} -eq 0 ]]; then
			git pull  >>${log} 2>&1
			echo "######### ${repo_name} #########" >> ${commit_id_file}
			if [[ ${branch_type} == "code" ]]; then
				echo ">>>>>>>> delete branch = ${GITHUB_YOCTO_BRANCH} START" >> ${log}
				git push origin :${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
				git branch -D ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
				echo ">>>>>>>> delete branch = ${GITHUB_YOCTO_BRANCH} END" >> ${log}
				echo ""  >> ${log}
			else
				echo ">>>>>>>> delete branch = ${GITHUB_MKDOCS_BRANCH} START" >> ${log}
				git push origin :${GITHUB_MKDOCS_BRANCH}  >>${log} 2>&1
				git branch -D ${GITHUB_MKDOCS_BRANCH}  >>${log} 2>&1
				echo ">>>>>>>> delete branch = ${GITHUB_MKDOCS_BRANCH} END" >> ${log}
				echo ""  >> ${log}
			fi
			if [[ ${branch_type} == "draft" ]]; then
				echo ">>>>>>>> delete branch = ${GITHUB_DRAFT_BRANCH} START" >> ${log}
				git push origin :${GITHUB_DRAFT_BRANCH}  >>${log} 2>&1
				git branch -D ${GITHUB_DRAFT_BRANCH}  >>${log} 2>&1
				echo ">>>>>>>> delete branch = ${GITHUB_DRAFT_BRANCH} END" >> ${log}
			fi
		fi
		popd >> ${log}
		echo ">>>>>>>> ${repo_name} => create github branch end <<<<<<<<" | tee -a ${log}
		echo "" >> ${log}
		echo "" >> ${log}
	done
}

function create_hotfix_branch ()
{
	local log="${WORK_PATH}/${GITHUB_HOTFIX_TARGS}_create_hotfix_branch.log"
	local commit_id_file="${WORK_PATH}/${GITHUB_HOTFIX_TARGS}_hotfix_commit_id.txt"
	:> ${log}
	:> ${commit_id_file}
	for repo_info in ${HOTFIX_GIT_REPO_LIST[@]}; do
		tmp_array=(${repo_info//:/ })
		group_name=${tmp_array[0]}
		repo_name=${tmp_array[1]}
		branch_type=${tmp_array[2]}
		ret_code=0

		echo ">>>>>>>> ${repo_name} => create github branch start <<<<<<<<" | tee -a ${log}
		github_repo_name="${repo_name}_github"
		# git update
		if [[ -d ${github_repo_name} ]] && [[ -e ${github_repo_name}/.git ]] ; then
			pushd ${github_repo_name} >> ${log}
			{
				git reset --hard HEAD >/dev/null 2>&1
				git clean -df >/dev/null 2>&1
				git remote update origin --prune >/dev/null 2>&1
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		else
			## gitlab clone
			git clone --progress "${GITHUB_URL}/${group_name}/${repo_name}.git" ${github_repo_name} 2>${WORK_PATH}/.git_progress.log
			pushd ${github_repo_name} >> ${log}
			{
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		fi
		# create branch
		if [[ ${ret_code} -eq 0 ]]; then
			git pull  >>${log} 2>&1
			echo "######### ${repo_name} TARGS ${GITHUB_HOTFIX_TARGS} #########" >> ${commit_id_file}
			SRCREV="MASTER_commit_id = \"$(git rev-parse HEAD)\""
			echo ${SRCREV}  >> ${commit_id_file}
			if [[ ${branch_type} == "code" ]]; then
				echo ">>>>>>>> create branch = ${GITHUB_HOTFIX_YOCTO} START" >> ${log}
				git checkout -b ${GITHUB_HOTFIX_YOCTO} ${GITHUB_HOTFIX_TARGS} >>${log} 2>&1
				git push -f origin ${GITHUB_HOTFIX_YOCTO}  >>${log} 2>&1
				SRCREV="${GITHUB_HOTFIX_YOCTO}_commit_id = \"$(git rev-parse HEAD)\""
				echo ${SRCREV}  >> ${commit_id_file}
				echo "" >> ${commit_id_file}
				git checkout master  >>${log} 2>&1
				git branch -D ${GITHUB_HOTFIX_YOCTO}  >>${log} 2>&1
				echo ">>>>>>>> create branch = ${GITHUB_HOTFIX_YOCTO} END" >> ${log}
				echo "" >> ${log}
			else
				echo ">>>>>>>> create branch = ${GITHUB_HOTFIX_MKDOCS} START" >> ${log}
				git checkout -b ${GITHUB_HOTFIX_MKDOCS} ${GITHUB_HOTFIX_TARGS} >>${log} 2>&1
				git push -f origin ${GITHUB_HOTFIX_MKDOCS}  >>${log} 2>&1
				SRCREV="${GITHUB_HOTFIX_MKDOCS}_commit_id = \"$(git rev-parse HEAD)\""
				echo ${SRCREV}  >> ${commit_id_file}
				git checkout master  >>${log} 2>&1
				git branch -D ${GITHUB_HOTFIX_MKDOCS}  >>${log} 2>&1
				echo ">>>>>>>> create branch = ${GITHUB_HOTFIX_MKDOCS} END" >> ${log}
			fi
			echo "" >> ${commit_id_file}
		fi
		popd >> ${log}
		echo ">>>>>>>> ${repo_name} => create github branch end <<<<<<<<" | tee -a ${log}
		echo "" >> ${log}
		echo "" >> ${log}
	done
}

function delete_hotfix_branch ()
{
	local log="${WORK_PATH}/${GITHUB_HOTFIX_TARGS}_delete_hotfix_branch.log"
	local commit_id_file="${WORK_PATH}/${GITHUB_HOTFIX_TARGS}_hotfix_commit_id.txt"
	:> ${log}
	:> ${commit_id_file}
	for repo_info in ${HOTFIX_GIT_REPO_LIST[@]}; do
		tmp_array=(${repo_info//:/ })
		group_name=${tmp_array[0]}
		repo_name=${tmp_array[1]}
		branch_type=${tmp_array[2]}
		ret_code=0

		echo ">>>>>>>> ${repo_name} => delete github branch start <<<<<<<<" | tee -a ${log}
		github_repo_name="${repo_name}_github"
		# git update
		if [[ -d ${github_repo_name} ]] && [[ -e ${github_repo_name}/.git ]] ; then
			pushd ${github_repo_name} >> ${log}
			{
				git reset --hard HEAD >/dev/null 2>&1
				git clean -df >/dev/null 2>&1
				git remote update origin --prune >/dev/null 2>&1
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		else
			## gitlab clone
			git clone --progress "${GITHUB_URL}/${group_name}/${repo_name}.git" ${github_repo_name} 2>${WORK_PATH}/.git_progress.log
			pushd ${github_repo_name} >> ${log}
			{
				git checkout master  >>${log} 2>&1
				ret_code=$?
			}
		fi
		# delete branch
		if [[ ${ret_code} -eq 0 ]]; then
			echo "######### ${repo_name} TARGS ${GITHUB_HOTFIX_TARGS} #########" >> ${commit_id_file}
			git pull  >>${log} 2>&1
			if [[ ${branch_type} == "code" ]]; then
				echo ">>>>>>>> delete branch = ${GITHUB_HOTFIX_YOCTO} START" >> ${log}
				git push origin :${GITHUB_HOTFIX_YOCTO}  >>${log} 2>&1
				git branch -D ${GITHUB_HOTFIX_YOCTO} >>${log} 2>&1
				echo ">>>>>>>> delete branch = ${GITHUB_HOTFIX_YOCTO} END" >> ${log}
				echo "" >> ${log}
			else
				echo ">>>>>>>> delete branch = ${GITHUB_HOTFIX_MKDOCS} START" >> ${log}
				git push origin :${GITHUB_HOTFIX_MKDOCS}  >>${log} 2>&1
				git branch -D ${GITHUB_HOTFIX_MKDOCS} >>${log} 2>&1
				echo ">>>>>>>> delete branch = ${GITHUB_HOTFIX_MKDOCS} END" >> ${log}
			fi
		fi
		popd >> ${log}
		echo ">>>>>>>> ${repo_name} => delete github branch end <<<<<<<<" | tee -a ${log}
		echo "" >> ${log}
		echo "" >> ${log}
	done
}

function create_yocto_build_txt_file ()
{
	local log="${WORK_PATH}/${SP}_creat_yocto_build_txt_file.log"
	local branch_info="${WORK_PATH}/${SP}_yocto_build_$(date +%Y%m%d%H%M%S).txt"
	:> ${log}
	:> ${branch_info}
	for repo_info in ${GIT_REPO_LIST[@]}; do
		tmp_array=(${repo_info//:/ })
		group_name=${tmp_array[0]}
		repo_name=${tmp_array[1]}
		branch_type=${tmp_array[2]}

		if [[ ${branch_type} == "code" ]]; then
			github_repo_name="${repo_name}_github"
			echo ">>>>>>>>>> ${repo_name} check start <<<<<<<<<<<<<<" | tee -a  ${log}
			if [[ -d ${github_repo_name} ]] && [[ -e ${github_repo_name}/.git ]]; then
				## github update
				pushd ${github_repo_name} >> ${log}
				{
					git reset --hard HEAD >/dev/null 2>&1
					git clean -df >/dev/null 2>&1
					git remote update origin --prune >/dev/null 2>&1
					git checkout master  >>${log} 2>&1
					git pull  >>${log} 2>&1
					git checkout ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
					ret_code=$?
				}
			else
				## github clone
				git clone --progress "${GITHUB_URL}/${group_name}/${repo_name}.git"  ${github_repo_name} 2>${WORK_PATH}/.git_progress.log
				pushd ${github_repo_name} >> ${log}
				{
					git pull  >>${log} 2>&1
					git checkout ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
					ret_code=$?
				}
			fi

			if [[ ${ret_code} -eq 0 ]]; then
				git pull  >>${log} 2>&1
				SRC_URI=${repo_name}_"SRC_URI = \"$(git remote get-url origin  | sed  's/https:/git:/g');protocol=https;branch=${GITHUB_YOCTO_BRANCH}\""
				SRCREV=${repo_name}_"SRCREV = \"$(git rev-parse HEAD)\""
				echo "######### ${repo_name} #########" >> ${branch_info}
				echo ${SRC_URI} >> ${branch_info}
				echo ${SRCREV}  >> ${branch_info}
				popd >> ${log}
				echo ">>>>>>>>>> ${repo_name} check end <<<<<<<<<<<<<<" | tee -a  ${log}
				echo "" | tee -a  ${log}
			fi
		fi
	done
}

function create_master_yocto_SRCREV ()
{
	local log="${WORK_PATH}/${SP}_yocto_build_compare.log"
	local branch_info="${WORK_PATH}/${SP}_yocto_build_compare.txt"
	:> ${log}
	:> ${branch_info}
	for repo_info in ${GIT_REPO_LIST[@]}; do
		tmp_array=(${repo_info//:/ })
		group_name=${tmp_array[0]}
		repo_name=${tmp_array[1]}
		branch_type=${tmp_array[2]}

		if [[ ${branch_type} == "code" ]]; then
			github_repo_name="${repo_name}_github"
			echo ">>>>>>>>>> ${repo_name} check start <<<<<<<<<<<<<<" | tee -a  ${log}
			if [[ -d ${github_repo_name} ]] && [[ -e ${github_repo_name}/.git ]]; then
				## github update
				pushd ${github_repo_name} >> ${log}
				{
					git pull  >>${log} 2>&1
					git checkout master  >>${log} 2>&1
					MASTER_SRCREV="MASTER_SRCREV = \"$(git rev-parse HEAD)\""
					git checkout ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
					ret_code=$?
					git pull  >>${log} 2>&1
				}
			else
				## github clone
				git clone --progress "${GITHUB_URL}/${group_name}/${repo_name}.git"  ${github_repo_name} 2>${WORK_PATH}/.git_progress.log
				pushd ${github_repo_name} >> ${log}
				{
					git checkout master  >>${log} 2>&1
					MASTER_SRCREV="MASTER_SRCREV = \"$(git rev-parse HEAD)\""
					git checkout ${GITHUB_YOCTO_BRANCH}  >>${log} 2>&1
					ret_code=$?
					git pull  >>${log} 2>&1
				}
			fi

			if [[ ${ret_code} -eq 0 ]]; then
				SRC_URI=${repo_name}_"SRC_URI = \"$(git remote get-url origin  | sed  's/https:/git:/g');protocol=https;branch=${GITHUB_YOCTO_BRANCH}\""
				SRCREV=${repo_name}_"SRCREV = \"$(git rev-parse HEAD)\""
				echo "######### ${repo_name} #########" >> ${branch_info}
				echo ${MASTER_SRCREV} >> ${branch_info}
				echo ${SRC_URI} >> ${branch_info}
				echo ${SRCREV}  >> ${branch_info}
				popd >> ${log}
				echo ">>>>>>>>>> ${repo_name} check end <<<<<<<<<<<<<<" | tee -a  ${log}
				echo "" | tee -a  ${log}
			fi
		fi
	done
}

########################################################
# main
########################################################
while :
do
    echo "#####################################################################"
    echo "#         Please select one of the options below to proceed         #"
    echo "# Options:                                                          #"
    echo "#         1   create release and draft branch                       #"
    echo "#         2   create Hotfix branch                                  #"
    echo "#         3   create yocto build txt file                           #"
    echo "#         4   delete release and draft branch                       #"
    echo "#         5   delete Hotfix branch                                  #"
    echo "#         6   create master yocto compare result file               #"
    echo "#         0   exit                                                  #"
    echo "#####################################################################"

    read -p "Please enter your options:" options
    echo ""
    
    case ${options} in
            1)
                echo "[NORMAL] >>>>>> create release and draft branch Start !<<<<<<"
                create_release_branch
                echo "[NORMAL] >>>>>> create release and draft branch  End  !<<<<<<"
				exit 0
                ;;
            2)
                echo "[NORMAL] >>>>>> create hotfix branch Start !<<<<<<"
                create_hotfix_branch
                echo "[NORMAL] >>>>>> create hotfix branch  End  !<<<<<<"
				exit 0
                ;;
            3)
                echo "[NORMAL] >>>>>> creat_yocto_build_txt_file  Start !<<<<<<"
                create_yocto_build_txt_file
                echo "[NORMAL] >>>>>> creat_yocto_build_txt_file End  !<<<<<<"
				exit 0
                ;;
            4)
                echo "[NORMAL] >>>>>> delete_yocto_build_txt_file  Start !<<<<<<"
                delete_release_branch
                echo "[NORMAL] >>>>>> delete_yocto_build_txt_file End  !<<<<<<"
				exit 0
                ;;
            5)
                echo "[NORMAL] >>>>>> delete_hotfix_branch  Start !<<<<<<"
                delete_hotfix_branch
                echo "[NORMAL] >>>>>> delete_hotfix_branch End  !<<<<<<"
				exit 0
                ;;
            6)
                echo "[NORMAL] >>>>>> create master yocto compare result file  Start !<<<<<<"
                create_master_yocto_SRCREV
                echo "[NORMAL] >>>>>> create master yocto compare result file  End  !<<<<<<"
				exit 0
                ;;
            0)
                echo "[NORMAL] --exit 0--"
                exit 0
                ;;
            *)
                echo "[ERROR ] ------wrong option = [ ${options} ]!!!------"
                ;;
    esac
done
